//index.js
import { filter, setParam} from './filter.js'
import demoData from './data.js'
let ASC = true;
let DESC = false;
//获取应用实例
const app = getApp()



Page({
  data: {
    createTime: ASC, //true 为 asc; false 为 desc
    commitCount: ASC, //true 为 asc; false 为 desc
    selectedAddress: '',
    currentAddress: '',
    currentAddressCode: '110100', //默认在北京
    areaList: [],
    provinceList: [],
    filter: {}, //筛选参数
  },
  selectParam(e) {
    let dataset = e.currentTarget.dataset;  //标签中设置的参数值
    let inputValue = e.detail.value; // 输入框输入的参数值
    let param = setParam(dataset, inputValue);
    console.info('用户新添加的参数:', param);
    //更新参数
    let allParam = filter.update(param);
    console.log('用户添加的参数(汇总):', allParam);
    this.setData({ filter: allParam });
    console.log('this.data.filter:', this.data.filter);
    console.log('接口参数:', filter.getParamForHttp());
  },
  initData(){
    this.setData({
      provinceList: demoData.provinceList
    });
  },
  onLoad: function () {
   this.initData();
  }
})
